<?$helper=new View_Helper_Image();
$helperDate=new View_Helper_Date();?>
<?if (isset($this->proposalUpload)):?>
    <div id="panel-form">
        <h2><?=($this->proposalUpload)?"His proposal is properly registered.":"An error occurred when registering your proposal"?></h2>
        <div><a id="back-project">Back</a></div>
    </div>
<?endif;?>

<div id="panel-project" <?=isset($this->proposalUpload)?"style='display:none'":""?>>
    <div id="tabs">
	<ul>
		<li><a href="#tabs-1">Home</a></li>
                <?if(count($this->collaborators)>0):?>
                    <li><a href="#tabs-2">Collaborators</a></li>
                <?endif;?>
                <?if($this->project->titulo_concurso!=""):?>
                    <li><a href="#tabs-3">Contests</a></li>
                <?endif?>
                <?if(count($this->actualizaciones)>0):?>
                    <li><a href="#tabs-4">Updates (<?=count($this->actualizaciones)?>)</a></li>
                <?endif?>
                <?if(count($this->attendes)>0):?>
                    <li><a href="#tabs-5">Attendes (<?=count($this->attendes)?>)</a></li>
                <?endif?>
	</ul>
	<div id="tabs-1">
            <div id="ficha">
                <div id="ficha-iconos"></div>
                <input type="hidden" id="link" value="<?=$this->project->link_rewrite?>"/>
                <input type="hidden" id="closed" value="<?=$this->closed?"1":""?>"/>
                <?if ($this->setConcurso):?>
                    <input type="hidden" id="set_concurso" value="1"/>
                <?endif;?>
                <div id="votos">
                    <!--<div>
                        <a id="down"><img src="/img/down.png"></a>
                        <span id="ldown">(<?=$this->votos['negativos']?>)</span>
                    </div>-->
                    <div>
                        <a id="up"><img src="/img/up.png"></a>
                        <span id="lup">(<?=$this->votos['positivos']?>)</span>
                    </div>
                </div>
                <h1><span>Event: </span><?=$this->project->titulo?> - <?=$this->project->ciudad?>(<?=implode("/",array_reverse(explode("-",$this->project->fecha)))?>) </h1>
                <div id="ficha-imagen"><img src="<?=$this->image?>"></div>
                
                <div id="ficha-info">
                    <div class="number"><span id="porcentaje"><?=round($this->porcentaje,0)?></span> %</div>
                    <div class="text">raised</div>
                    <div id="progressbar"></div>
                    <?if(round($this->project->importe_solicitado,0)>0):?>
                    <div class="text"><?=round($this->recaudado,0)?> of <?=round($this->project->importe_solicitado,0)?> &euro;</div>
                    <?endif;?>
                    <div class="number margin"><?=$this->numApoyos?></div>
                    <div class="text">attendees</div>
                    <?if(!$this->closed):?>
                    <div class="number margin"><?=$this->days?></div>
                    <div class="text">days</div>
                    <?else:?>
                    <div class="number margin">Closed</div>
                    <div class="text">The deadline has ended</div>
                    <?endif;?>
                </div>
                <?if (strlen($this->project->video_embed)>10):?>
                    <div id="ficha-video"><?=$this->project->video_embed?></div>
                <?endif;?>

                <div id="ficha-bottom">
                    <div id="project-social">
                        <a href="http://www.facebook.com/sharer.php?u=<?=$this->url?>&r=<?=rand(0,1000)?>&t=<?=$this->project->titulo?>" target="_blank"><img src="/img/fb_ico.png"/></a>
                        <a href="http://twitter.com/share?original_referer=<?=$this->url?>&source=tweetbutton&text=<?=$this->project->titulo?>" target="_blank" ><img src="/img/tw.png"/></a>
                        <a href="http://www.linkedin.com/cws/share?original_referer=<?=$this->url?>&url=<?=$this->url?>" target="_blank"><img src="/img/in.png"/></a>
                        <!--<a href="http://www.tuenti.com/share?url=<?=$this->url?>" target="_blank"><img src="/img/tu.png"/></a>-->
                        
                    </div>
                    <h2>Description</h2>
                    <span id="descripcion"><?=nl2br($this->project->descripcion)?></span>
                </div>
            </div>
	</div>
        <?if(count($this->collaborators)>0):?>
	<div id="tabs-2">
            <div id="colaboradores">
                <?foreach($this->collaborators as $collaborator):?>
                    <div class="colaborador">
                        <h2><?=$collaborator['colaborador']?></h2>
                        <p class="contacto"><?=$collaborator['contacto']?></p>
                        <p><?=$collaborator['descripcion_colaborador']?></p>
                    </div>
                <?endforeach;?>
                
            </div>
	</div>
        <?endif;?>
        <?if($this->project->titulo_concurso!=""):?>
	<div id="tabs-3">
            <div id="concurso">
                <h2 class="unescape"><?=$this->project->titulo_concurso?></h2>
		<p class="unescape"><?=nl2br($this->project->descripcion_concurso)?></p>
                <?if(count($this->proposals)==0):?>
                    <div class="propuesta">There are still no proposals can be the first.</div>
                <?endif;?>

                <?foreach($this->proposals as $proposal):?>
                    <div class="propuesta">
                        <div id="votos">
                            <!--<div>
                                <a id="down-<?=$proposal['id_propuesta']?>" class="down"><img src="/img/down.png"></a>
                                <span id="ldown-<?=$proposal['id_propuesta']?>">(<?=$proposal['votes']['negativos']?>)</span>
                            </div>-->
                            <div>
                                <a id="up-<?=$proposal['id_propuesta']?>"" class="up"><img src="/img/up.png"></a>
                                <span id="lup-<?=$proposal['id_propuesta']?>">(<?=$proposal['votes']['positivos']?>)</span>
                            </div>
                        </div>
                        <h3<a class="username "href="/user/perfil/<?=$proposal['username']?>"><?=$proposal['username']?> proposal</a></h3>

                            <p><?=nl2br($proposal['propuesta'])?></p>
                            <?if($proposal['adjunto']!=""):

                                    $path=$_SERVER['DOCUMENT_ROOT']."/admin/".$proposal['adjunto'];
                                    $imagen=(@imagecreatefromjpeg($path) || @imagecreatefromgif($path) || @imagecreatefrompng($path));
                                    if($imagen):?>
                                    <a href="/admin/<?=$proposal['adjunto']?>" target="_blank"><img alt="Abrir en otra ventana" title="Abrir en otra ventana" src="/admin/<?=$proposal['adjunto']?>"></a>
                                <?else:?>
                                    <a href="/admin/<?=$proposal['adjunto']?>" target="_blank">Attached<?=$type?></a>
                                <?endif;?>
                            <?endif;?>
                        <!--<img src="<?=$helper->image($proposal['id_usuario'], $proposal['imagen'])?>">-->
                        <div class="fecha"><?=$helperDate->Date2DateComment($proposal['fecha'])?></div>
                        <div>
                            <a class="show_comments" id="<?=$proposal['id_propuesta']?>"><?=(count($proposal['comments'])==0)?"Comentar":"Mostrar comentarios(".count($proposal['comments']).")"?></a>
                            </div>
                        <div id="comentarios_concurso_<?=$proposal['id_propuesta']?>" class="comentarios-concurso">

                            <div id="comentarios_<?=$proposal['id_propuesta']?>">
                                <?if(is_array($proposal['comments'])):
                                        foreach($proposal['comments'] as $comment):?>
                                    <div class="comentario-concurso">
                                        <img src="<?=$helper->image($comment['id_usuario'], $comment['imagen'])?>">
                                        <div>
                                            <span><a href="/user/perfil/<?=$comment['username']?>"><?=$comment['username']?></a></span>
                                            <?=$comment['comentario']?>
                                        </div>
                                        <div class="fecha"><?=$helperDate->Date2DateComment($comment['fecha'])?></div>
                                        <div class="cl"></div>
                                    </div>
                                <?endforeach;
                                        endif;?>
                            </div>
                            <div id="entrada" >
                                <div><textarea name="txt-comentario-<?=$proposal['id_propuesta']?>" id="txt-comentario-<?=$proposal['id_propuesta']?>"  cols="40" rows="1"></textarea></div>
                                <div><input type="button" id="<?=$proposal['id_propuesta']?>" class="add-comentario btn-red" value="Comment"/></div>
                            </div>
                        </div>
                    </div>
                <?endforeach;?>
                <div id="proponer"><input type="button" id="add-propuesta" class="btn-red" value="Propose"/></div>
                
            </div>
	</div>
        <?endif;?>
        <?if(count($this->actualizaciones)>0):?>
        <div id="tabs-4">

            <div id="colaboradores">
                <?foreach($this->actualizaciones as $actualizacion):?>
                    <div class="colaborador">
                        <h2><?=$actualizacion['fecha_actualizacion']?></h2>
                        <p class="propuesta"><?=$actualizacion['actualizacion']?></p>
                    </div>
                <?endforeach;?>

            </div>
        </div>
        <?endif;?>
        <?if(count($this->attendes)>0):?>
        <div id="tabs-5">

            <div id="attendes">
                <?foreach($this->attendes as $attende):?>
                    <div class="attende">
                        <a href="/user/perfil/<?=$attende['username']?>"><img src="<?=$helper->image($attende['id_usuario'], $attende['imagen'])?>"></a>
                        <div>
                            <span><a href="/user/perfil/<?=$attende['username']?>"><?=$attende['username']?></a></span>
                        </div>
                    </div>
                <?endforeach;?>
                <div class="cl"></div>
            </div>
        </div>
        <?endif;?>
    </div>
    <div id="recompensas">
        <input type="hidden" id="id-recompensa"/>
        <input type="hidden" id="apoyo-minimo"/>
        <span>Vip Tickets</span>
        <ul class="scroll-content-item ui-widget-header">
            <?foreach($this->rewards as $reward):?>
            <li>
                <div class="recompensa-valor"><?=$reward->apoyo_minimo?>&euro;</div>
                <div class="recompensa-desc"><?=$reward->recompensa?></div>
                <div id="<?=$reward->id_recompensa."_".$reward->apoyo_minimo?>" class="btn-red">Support</div>
            </li>
            <?endforeach;?>
            
        </ul>
        <?if(count($this->rewardsSale)>0):?>
            <span>Limited rewards</span>
            <p>Only taken into account the highest support</p>
            <ul class="scroll-content-item ui-widget-header">
                <?foreach($this->rewardsSale as $reward):?>
                <li>
                    <div class="recompensa-valor"><?=$reward->apoyo_minimo?>&euro;</div>
                    <div class="recompensa-desc"><?=$reward->recompensa?></div>
                    <div id="<?=$reward->id_recompensa."_".$reward->apoyo_minimo?>" class="btn-red">Support</div>
                </li>
                <?endforeach;?>

            </ul>
        <?endif;?>
    </div>
    <div class="cl"></div>
    <div id="comentarios">
        <?foreach($this->comments as $comentario):?>
            <div class="comentario">
                <img src="<?=$helper->image($comentario['id_usuario'], $comentario['imagen'])?>">
                <div>
                    <span><a href="/user/perfil/<?=$comentario['username']?>"><?=$comentario['username']?></a></span>
                    <?=$comentario['comentario']?>
                </div>
                <div class="fecha">
                    <?=$helperDate->Date2DateComment($comentario['fecha'])?>
                </div>
                <div class="cl"></div>
            </div>
        <?endforeach?>
    </div>
    <div id="entrada" >
        <div><textarea name="comentario" id="txt-comentario" cols="80" rows="2"></textarea></div>
        <div><input type="button" id="add-comentario" class="btn-red" value="Comment"/></div>
    </div>
    <div class="cl"></div>
</div>
<div id="dialog-form" title="Support the event">
    <div>
	<p class="validateTips"></p>

	<form>
	<fieldset>
            <table>
                <tr>
		<td><label for="amount">Amount by which support</label></td>
		<td><input type="text" name="amount" id="amount" class="text ui-widget-content ui-corner-all" /></td>
                </tr><input type="hidden" name="sponsor" id="sponsor" maxlength="10" size="12" class="text ui-widget-content ui-corner-all" />
                
                </table>
	</fieldset>
	</form>
    </div>
</div>
<?if($this->msg!=""):?>
    <div id="dialog-form-aviso" title="Notice">
        <div>
            <?=$this->msg?>
        </div>
    </div>
<?endif;?>

<div id="dialog-form-proposal" title="Make your proposal">
    <div>
	<p class="validateTips"></p>

        <form id="do-proposal" enctype="multipart/form-data"  method="post">
	<fieldset>
		<label for="proposal">Describe your proposal</label><br/>
		<textarea name="proposal" id="proposal" class="text ui-widget-content ui-corner-all"></textarea><br/>
                <label for="attached">attached(optional)</label><br/>
		<input type="file" name="attached" id="attached" class="text ui-widget-content ui-corner-all" />
	</fieldset>
	</form>
    </div>
</div>
